/**
    File        : IPlugin.h
    Description : Virtual classes for creating plugins
    Author      : Raymond Marsh
    Created     : 08/01/2009
    Copyright 2009, 2010, 2011, 2012 Raymond Marsh

    This program is distributed under the terms of the GNU General Public License.
    To view a copy of the license see the file 'copying.txt'

    This file is part of the MyMoney Suite.

    MyMoney is free software: you can redistribute it and/or modify it under
    the terms of the GNU General Public License as published by the Free Software Foundation, either
    version 3 of the License, or (at your option) any later version.

    MyMoney is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with MyMoney.
    If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef IPLUGIN_H_INCLUDED
#define IPLUGIN_H_INCLUDED

//#include <wx/event.h>
#include <wx/dialog.h>
#include <wx/toolbar.h>
#include <wx/menu.h>
#include <wx/dynlib.h>
#include <wx/radiobox.h>
#include <wx/sizer.h>
//#include <wx/arrstr.h>

//#include <vector>
#include <vector>

#include "stdafx.h"
#include "ErrorLog.h"

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#ifdef MYMONEY_PLUGIN_EXPORTS
#define DLL_IMPORT_EXPORT __declspec(dllexport)
#else
#define DLL_IMPORT_EXPORT __declspec(dllimport)
#endif

enum PLUGIN_TYPE
{
    PT_ACCOUNTTYPE = 9150,
    PT_REPORT
};

class CData;
class CPluginHost;

class CPluginBase
{
public:
    virtual ~CPluginBase() { }
    virtual void InitializePlugin(CPluginHost*)                        = 0;
    virtual void ShutdownPlugin()                                      = 0;
    virtual wxString GetPluginName()                                   = 0;
    virtual PLUGIN_TYPE GetPluginType()                                = 0;
    virtual wxString GetPluginVersionString()                          = 0;
    virtual wxString GetWxVersionString()                              = 0;
};

class CAccountPlugin : public CPluginBase
{
public:
    virtual ~CAccountPlugin() { }
    virtual int GetColumnInfo(std::vector<SColumn>& Columns)           = 0;
    virtual wxString GetTransactionDisplay(wxWindow*,
                                           wxBoxSizer**,
                                           STransaction&,
                                           const bool,
                                           const bool)                 = 0;
    virtual wxRadioBox* GetTransactionTypeDisplay(wxWindow*,
                                                  STransaction&,
                                                  const bool,
                                                  const bool)          = 0;
    virtual wxSizer* GetTransactionDetailDisplay(wxWindow*,
                                                 STransaction&,
                                                 const bool,
                                                 const bool)           = 0;
    virtual bool ShowControls()                                        = 0;
    virtual wxString ValidateData(wxString*, wxString*)                = 0;
    virtual bool UnbindHandlers(wxWindow* pParent)                     = 0;
};

class CReportPlugin : public wxDialog, public CPluginBase
{
public:
    virtual ~CReportPlugin() { }
};

class CPluginHost
{
public:
    virtual ~CPluginHost() { }
    virtual long GetNewId()                                             = 0;
    virtual wxEvtHandler* GetEvtHandler()                               = 0;
    virtual wxMenuBar* GetMainMenuBar()                                 = 0;
    virtual wxToolBar* GetMainToolBar()                                 = 0;
    virtual CData* GetData()                                            = 0;
    virtual bool GetAvailableAccountTypes(wxArrayString&)               = 0;
    virtual wxArrayString GetCategoryList()                             = 0;
    virtual wxArrayString GetSubCategoryList(wxString&)                 = 0;
};

typedef bool (*DLLFunctionInitPtr)(CPluginBase**);
typedef bool (*DLLFunctionInfoPtr)(wxString*);

struct SPluginInfo
{
    wxString            PluginName;
    PLUGIN_TYPE         PluginType;
    wxString            PluginVersion;
    wxString            WXVersion;
    CPluginBase*        pPluginObject;
    wxDynamicLibrary*   pLibLoader;
    DLLFunctionInitPtr  pFuncRegisterPlugin;
    DLLFunctionInitPtr  pFuncUnregisterPlugin;
    SPluginInfo() : pLibLoader(NULL), pPluginObject(NULL), pFuncRegisterPlugin(NULL), pFuncUnregisterPlugin(NULL) { }
};

#ifdef __cplusplus
}
#endif // __cplusplus


#endif // IPLUGIN_H_INCLUDED
